<admintpl file="header" />
</head>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li class="active"><a>{:L('USER_INDEXADMIN_INDEX')}</a></li>
			<!--<li><a href="{:U('indexadmin/myuser')}">我的客户</a></li>-->
			<li><a href="{:U('indexadmin/add')}">添加推广客户</a></li>
		</ul>
		<php>$group=get_groups_admin_user();</php>
		<form class="well form-search" method="post" action="{:U('Indexadmin/index')}" style='line-height: 46px;'>
			手机号码： 
			<input type="text" name="mobile" style="width: 150px;" value="{:I('request.mobile')}" placeholder="请输入手机号码">
			姓名： 
			<input type="text" name="name" style="width: 150px;" value="{:I('request.name')}" placeholder="姓名">
			身份证：<input type="text" name="identity" style="width: 150px;" value="{:I('request.identity')}" placeholder="身份证">
			注册日期：<input class="js-date" type="text" name="starts" style="width: 150px;" value="{:I('request.starts')}" placeholder="起始时间">
			<input class="js-date" type="text" name="ends" style="width: 150px;" value="{:I('request.ends')}" placeholder="结束时间">
			<br />
			资料审核状态：<select name="type">
				<option value="">全部</option>
				<php>$tpl_selected=I('request.type')=='0'?"selected":"";</php>
				<option {$tpl_selected} value="0">待绑卡</option>
				<php>$tpl_selected=I('request.type')=='1'?"selected":"";</php>
				<option {$tpl_selected} value="1">上传证件照</option>
				<php>$tpl_selected=I('request.type')=='2'?"selected":"";</php>
				<option {$tpl_selected} value="2">待审核</option>
				<php>$tpl_selected=I('request.type')=='3'?"selected":"";</php>
				<option {$tpl_selected} value="3">学信认证</option>
				<php>$tpl_selected=I('request.type')=='4'?"selected":"";</php>
				<option {$tpl_selected} value="4">填写联系信息</option>
				<php>$tpl_selected=I('request.type')=='5'?"selected":"";</php>
				<option {$tpl_selected} value="5">信息填写完成</option>
				<php>$tpl_selected=I('request.type')=='8'?"selected":"";</php>
				<option {$tpl_selected} value="8">系统审核不通过</option>
			</select>
			借款状态：<select name="type_borr">
				<option value="">全部</option>
				<php>$tpl_selected=I('request.type_borr')=='0'?"selected":"";</php>
				<option {$tpl_selected} value="0">待申请借款</option>
				<php>$tpl_selected=I('request.type_borr')=='1'?"selected":"";</php>
				<option {$tpl_selected} value="1">待填写运营商信息</option>
				<php>$tpl_selected=I('request.type_borr')=='2'?"selected":"";</php>
				<option {$tpl_selected} value="2">借款中</option>
				<php>$tpl_selected=I('request.type_borr')=='3'?"selected":"";</php>
				<option {$tpl_selected} value="3">不通过</option>
			</select>
			当前订单状态：
			<select name="status">
				<option value="">全部</option>
				<option value="0">待审核</option>
				<option value="1">借款中</option>
				<option value="2">已还款</option>
				<option value="3">逾期</option>
				<option value="4">已到期</option>
				<option value="5">审核中</option>
				<option value="6">审核不通过</option>
				<option value="7">驳回</option>
				<option value="8">放款成功</option>
				<option value="9">放款不成功</option>
				<option value="10">待放款</option>
			</select>
			<script>
				$('select[name="status"]').find('option[value="{:I(\'request.status\')}"]').prop('selected',true);
			</script>
			认领状态：<select name="byusers">
				<php>$tpl_selected=I('request.byusers')=='3'?"selected":"";</php>
				<option {$tpl_selected} value="3">全部</option>
				<php>$tpl_selected=I('request.byusers')=='1'?"selected":"";</php>
				<php>$tpl_selected=I('request.byusers')==''?"selected":$tpl_selected;</php>
				<option {$tpl_selected} value="1">未认领</option>
				<php>$tpl_selected=I('request.byusers')=='2'?"selected":"";</php>
				<option {$tpl_selected} value="2">已认领</option>
			</select>
			<br/>
			回流状态：<select name="reflux_status">
				<php>$tpl_selected=I('request.reflux_status')=='3'?"selected":"";</php>
				<php>$tpl_selected=I('request.reflux_status')==''?"selected":$tpl_selected;</php>
				<option {$tpl_selected} value="3">全部</option>
				<php>$tpl_selected=I('request.reflux_status')=='1'?"selected":"";</php>
				<option {$tpl_selected} value="1">正常用户</option>
				<php>$tpl_selected=I('request.reflux_status')=='2'?"selected":"";</php>
				<option {$tpl_selected} value="2">回流客户</option>
			</select>
			资料认证状态：
			<php>
				$ac_status_arr=array('-1'=>'全部','0'=>'未认证','1'=>'已认证','2'=>'认证未通过','3'=>'暂时不需要的','4'=>'除了已认证',);
			</php>
			<select name="account_status">
				<foreach name="ac_status_arr" item="at" key="k">
					<option <if condition="$account_status eq $k">selected</if> value="{$k}">{$at}</option>
				</foreach>
			</select>
			
			分销状态：<select name="is_dis">
				<php>$tpl_selected=I('request.is_dis')=='3'?"selected":"";</php>
				<option {$tpl_selected} value="3">全部</option>
				<php>$tpl_selected=I('request.is_dis')=='2'?"selected":"";</php>
				<option {$tpl_selected} value="2">推广客户</option>
				<php>$tpl_selected=I('request.is_dis')=='1'?"selected":"";</php>
				<php>$tpl_selected=I('request.is_dis')==''?"selected":$tpl_selected;</php>
				<option {$tpl_selected} value="1">正常用户</option>
			</select>
			<input type="submit" class="btn btn-primary" value="搜索" />
			<a class="btn btn-danger" href="{:U('Indexadmin/index')}">清空</a>
			<br/>
			<button class="btn btn-primary js-ajax-submit" type="button" id='add_bate' data-action="{:U('indexadmin/bate_add')}" onclick='check(1)' >批量认领</button>
			<button class="btn btn-primary js-ajax-submit" type="button" id='add_bate2' data-action="{:U('indexadmin/batch_add_reflux_user')}" onclick='check(2)' >批量添加回流用户</button>
			<a class="btn btn-primary" id='export_btn' href="{:U('indexadmin/export_app_user2',array('wheres'=>$wheres_str))}" >导出</a>
			
			<if condition="($group eq 1 || $group eq 8 || $group eq 10)">
			<button class="btn btn-primary js-ajax-trf" type="button" id='trf_bate' data-action="{:U('indexadmin/transfer')}" onclick='trf()' >转让</button>
			</if>
			渠道来源：<input type="text" name="qudao" style="width: 150px;" value="{:I('request.qudao')}" placeholder="渠道来源">
		</form>
		<form method="post" class="js-ajax-form">
			<php>$model = new \User\Model\ReportCurrentOrders();</php>
			<table class="table table-hover table-bordered" id='tab_check'>
				<thead>
					<tr>
						<th style='min-width: 30px;' align="center">选择</th>
						<th style='width: 66px;'>{:L('REGISTRATION_TIME')}</th>
						<th>{:L('NICENAME')}</th>
						<th style='min-width: 50px;'>{:L('IDENTITY')}</th>
						<th>芝麻分</th>
						<th style='min-width: 50px;'>手机</th>
						<th style='width: 35px;'>学历</th>
						<th>还款记录</th>
						<th style='min-width: 60px;'>{:L('USER_INFO')}</th>
						<th style='min-width: 50px;'>{:L('LOAN_INFO')}</th>
						<th style='min-width: 50px;'>当前<br />订单<br />状态</th>
						<th style='min-width: 50px;'>负责专员</th>
						<th style='min-width: 50px;'>资料认证状态</th>
						<th style='min-width: 50px;'>分销类型</th>
						<th style='min-width: 50px;'>审核失败原因</th>
						<th>渠道来源</th>
						<th>推荐码</th>
						<th>回流状态</th>
						<th>放款金额</th>
						<th  style='min-width: 50px;' align="center">{:L('ACTIONS')}</th>
					</tr>
				</thead>
				<tbody>
					<php>$user_statuses=array("0"=>L('USER_STATUS_BLOCKED'),"1"=>L('USER_STATUS_ACTIVATED'),"2"=>L('USER_STATUS_UNVERIFIED'));</php>
					<foreach name="list" item="vo">
					<tr>
						<td><input type='checkbox' name='id[]' value='{$vo.id}'/></td>
						<td>{$vo.crtime}</td>
						<php>
						if($group==3 || $group==8 || $group==10 || $group==6 || $group==13){
							if($vo['account_status']==1){
								$name=mb_substr($vo['name'],0,1,'utf-8').'**';
							}else{
								$name=$vo['name'];
							}
						}else{
							$name=$vo['name'];
						}
						</php>
						<td>{$name|default=L('NOT_FILLED')}</td>
						<php>$iden=substr($vo['identity'],6,8)</php>
						<td>{$iden}</td>
						<td>{$vo['sesame_score']}</td>
						<td>
							{$vo['photo_type']==1?'苹果':'安卓'}
							<if condition="$vo['photo_type']==1">
								<br/>【{$vo['accept_bind']==0?'不接受':'接受'}绑定】
							</if>
						</td>
						<td>{$vo.education}</td>
						<td>
							<empty name="vo['borr_record']">
								无
								<else/>
								{$vo['borr_record']}
							</empty>
						</td>
						<td>
							<if condition="($vo.type eq 0)"> 待绑卡
							<elseif condition="$vo.type eq 1"/>上传证件照
							<elseif condition="$vo.type eq 2"/>待审核
							<elseif condition="$vo.type eq 3"/>学信认证
							<elseif condition="$vo.type eq 4"/>填写联系信息
							<elseif condition="$vo.type eq 5" /> 信息填写完成
							<elseif condition="$vo.type eq 8" />系统审核不通过
							</if></td>
						<td>
							<if condition="($vo.type_borr eq 0)">待申请借款
							<elseif condition="$vo.type_borr eq 1"/>待填写运营商
							<elseif condition="$vo.type_borr eq 2"/>借款中
							<elseif condition="$vo.type_borr eq 3"/>审核不通过
							<elseif condition="$vo.type_borr eq 4"/>已提额待激活
							</if>
						</td>
						<td>
							<php>echo $model->getStatusText($vo['status']);</php>
						</td>
						<!-- <td>{$vo.last_login_time}</td> -->
						<td>{$buyers[$vo['byusers']]}</td>
						<php>$ds=array('0'=>'<span style="color:red">未认证</span>','1'=>'<span style="color:green">已认证</span>','2'=>'<span style="color:red">认证未通过</span>','3'=>'<span style="color:red">暂时不需要</span>')</php>
						<!-- <td>{$ds[$vo['silver_stutas']]}</td> -->
						<td>{$ds[$vo['account_status']]}</td>
						<!-- <td>{$user_statuses[$vo['user_status']]}</td> -->
						<td>{$vo['is_dis']==1?'推广':'正常'}</td>
						<td>{$unapproved[$vo['unapproved']]}</td>
						<td>{$codes[$vo['code']]|default=''}</td>
						<td>{$is_dis[$vo['id']]}</td>
						<td>
							<switch name="vo['reflux_status']">
								<case value="1">正常</case>
								<case value="2">审核成功</case>
								<default />回流用户
							</switch>
						</td>
						<td>
							<if condition="in_array((int)$vo['order_status'],[1,2,3,4,8])">
								{$vo['amount']}
								<else/>
								0
							</if>
						</td>
						<td align="center">
							<if condition="$send_sms[$vo['mobile']]">
							<else/>
							<a class="js-ajax-dialog-btn" data-msg="确定 {$vo['name']} 发送初审 通过 短信通知?" href="{:U('indexadmin/first_examine',array('user_id'=>$vo['id'],'type'=>1))}">初审通知通过</a>
							<a class="js-ajax-dialog-btn" data-msg="确定 {$vo['name']} 发送初审 未通过 短信通知?" href="{:U('indexadmin/first_examine',array('user_id'=>$vo['id'],'type'=>0))}">初审通知失败</a>
							<br/>
							</if>
							<if condition="($group eq 14)">
								<if condition="$vo['account_status'] neq 1" >
										<a href="{:U('indexadmin/see',array('id'=>$vo['id'],'from_type'=>1))}">客户详情</a>			
								</if>
								|<a href="{:U('indexadmin/info',array('id'=>$vo['id'],'dis'=>2))}" >{:L('MOD')}</a>
								<eq name="vo.account_status" value="0">
									<if condition="($vo.silver_stutas eq 0) or ($vo.silver_stutas eq 2)">
									<!-- <br />|<a href="{:U('indexadmin/examine',array('id'=>$vo['id']))}">实名认证</a> -->
									</if>
									<if condition="($vo.silver_stutas eq 1)">
									
									</if>
									<br />|<a href="{:U('indexadmin/contact_exam',array('id'=>$vo['id']))}">资料认证审核</a>
								</eq>
								<if condition="($vo.type eq 8)" >
										<br />|<a class="js-ajax-dialog-btn" data-msg="确定 {$vo['name']} 跳过系统认证?" href="{:U('indexadmin/type_exam',array('id'=>$vo['id']))}">跳过系统认证</a>				
								</if>
								<eq name="vo.type" value="5">
									<if condition="($vo.type_borr eq 1)">
									<br />|<a href="{:U('indexadmin/jum_ban',array('id'=>$vo['id']))}" class="js-ajax-dialog-btn" data-msg="确定 {$vo['name']} 跳过运营商验证?">跳过运营商验证</a>
									</if>
									<if condition="($vo.type_borr eq 2)">
									<br />|<a href="{:U('indexadmin/jum_ban',array('id'=>$vo['id'],'type'=>1))}" class="js-ajax-dialog-btn" data-msg="确定 {$vo['name']} 重新验证运营商?">重新验证运营商</a>
									</if>
								</eq>
							<else/>
								<if condition="($group eq 13 || $group eq 6)">
									<if condition="$vo['account_status'] neq 1" >
										<a href="{:U('indexadmin/see',array('id'=>$vo['id'],'from_type'=>1))}">客户详情</a>
									</if>
								<else/>
									<a href="{:U('indexadmin/see',array('id'=>$vo['id'],'from_type'=>1))}">客户详情</a>
								</if>
								|<a href="{:U('indexadmin/info',array('id'=>$vo['id'],'dis'=>2))}" >{:L('MOD')}</a>
								<eq name="vo.account_status" value="0">
									<if condition="($vo.silver_stutas eq 0) or ($vo.silver_stutas eq 2)">
									<!-- <br />|<a href="{:U('indexadmin/examine',array('id'=>$vo['id']))}">实名认证</a> -->
									</if>
									<if condition="($vo.silver_stutas eq 1)">
									
									</if>
									<br />|<a href="{:U('indexadmin/contact_exam',array('id'=>$vo['id']))}">资料认证审核</a>
								</eq>
								<if condition="($vo.type eq 8)" >
										<br />|<a class="js-ajax-dialog-btn" data-msg="确定 {$vo['name']} 跳过系统认证?" href="{:U('indexadmin/type_exam',array('id'=>$vo['id']))}">跳过系统认证</a>				
								</if>
								<eq name="vo.type" value="5">
									<if condition="($vo.type_borr eq 1)">
									<br />|<a href="{:U('indexadmin/jum_ban',array('id'=>$vo['id']))}" class="js-ajax-dialog-btn" data-msg="确定 {$vo['name']} 跳过运营商验证?">跳过运营商验证</a>
									</if>
									<if condition="($vo.type_borr eq 2)">
									<br />|<a href="{:U('indexadmin/jum_ban',array('id'=>$vo['id'],'type'=>1))}" class="js-ajax-dialog-btn" data-msg="确定 {$vo['name']} 重新验证运营商?">重新验证运营商</a>
									</if>
								</eq>
							</if>
						</td>
					</tr>
					</foreach>
				</tbody>
			</table>
			<div class="pagination">{$page}</div>
		</form>
	</div>
	<div id="dialog" style='display:none' >
	  <p>请选择转让的审核专员</p>
	  <ul style='width: 500px;list-style-type:none;'>
		<php>$i=0;</php>
		<foreach name="shen_user" item="vo">
		<li style='width: 110px;float: left;'><input type="radio" name='us_id' value='{$vo.id}' style='margin: 0 0 0 10px;'/>{$vo.user_login}</li>
		<php>$i++;</php>
		<if condition="($i eq 4)"><br/>
		<php>$i=0;</php>
		</if>
		</foreach>
	  </ul>
	</div>
	<script src="__PUBLIC__/js/common.js"></script>
	<script>
	function check(type){
        	var btn;
	    	if(1==type){
	    	    btn = $('button.js-ajax-submit').eq(0);
			}else if(2==type){
	    	    btn = $('button.js-ajax-submit').eq(1);
			}
			form = $('form.js-ajax-form');
			var obj=document.getElementsByName('id[]'); 
			var s=0; 
			for(var i=0; i<obj.length; i++){ 
				if(obj[i].checked) s+=1; 
			}
			if(s==0){
				alert('请选择客户');
				return ;
			}
			form.ajaxSubmit({
	                url: type ? btn.data('action') : form.attr('action'),
	                //按钮上是否自定义提交地址(多按钮情况)
	                dataType: 'json',
	                beforeSubmit: function (arr, $form, options) {
						var tx='批量添加';
	                    //按钮文案、状态修改
	                    btn.text(tx + '中...').attr('disabled', true).addClass('disabled');
	                },
	                success: function (data, statusText, xhr, $form) {
	                    //按钮文案、状态修改
	                    btn.removeClass('disabled').parent().find('span').remove();
	
	                    if (data.state === 'success') {
	                        $('<span class="tips_success">' + data.info + '</span>').appendTo(btn.parent()).fadeIn('slow').delay(1000).fadeOut(function () {
	                            if (data.referer) {
	                                //返回带跳转地址
	                                if (window.parent.art) {
	                                    //iframe弹出页
	                                    window.parent.location.href = data.referer;
	                                } else {
	                                    window.location.href = data.referer;
	                                }
	                            } else {
	                                if (window.parent.art) {
	                                    if(1==type){
	                                        reloadPage(window.parent);
										}else if(2==type){
	                                        window.location.reload();
										}
	                                } else {
	                                    //刷新当前页
	                                    reloadPage(window);
	                                }
	                            }
	                        });
	                    } else if (data.state === 'fail') {
	                        $('<span class="tips_error">' + data.info + '</span>').appendTo(btn.parent()).fadeIn('fast');
	                        btn.removeProp('disabled').removeClass('disabled');
	                    }
	                }
	            });
	}
	function trf(){
		var btn = $('#trf_bate');
		form = $('form.js-ajax-form');
		var obj=document.getElementsByName('id[]'); 
		var s=''; 
		for(var i=0; i<obj.length; i++){ 
			if(obj[i].checked){
				if(s==''){
					s=obj[i].value;
				}else{
					s+=','+obj[i].value;
				}
				
			}
		}
		if(s==''){
			alert('请选择客户');
			return ;
		}
		href = btn.data('action'),
		href = href ? href : $this.attr('href');
		Wind.use('artDialog', function () {
		//document.getElementById("dialog").style.display='block';
			 art.dialog({
				title: false,
				//icon: 'question',
				content: $("#dialog").html(),
				//content: '1111',
				follow: document.getElementById('trf_bate'),
				close: function () {
					return true;
				},
				ok: function () {
					var radio = document.getElementsByName("us_id"); 
					var us_id=0;
					for (i=0; i<radio.length; i++) {  
						if (radio[i].checked) {  
							us_id=radio[i].value;
						}  
					}
					if(us_id==0){
						alert('请选择审核专员');
						return false;
					}
					$.ajax({
							url:href,
							type:'post',
							dataType:'json',
							data:'users='+s+'&us_id='+us_id,
							success:function(map){
								if (map.state == 'success') {
											art.dialog({
											content: map.info,
											icon: 'success',
											ok: function () {
												this.title(map.info);
												return true;
											}
										});
								} else if (map.state == 'fail') {
									//art.dialog.alert(data.info);
									//alert(data.info);//暂时处理方案
									art.dialog({
										content: map.info,
										icon: 'warning',
										ok: function () {
											this.title(map.info);
											return true;
										}
									});
								}
							}
								
					}); 
				},
				cancelVal: '关闭',
				cancel: true
			});
		});
		
	}
	</script>
</body>
</html>